package com.xiaoma.bingox.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

import com.alibaba.fastjson.JSONObject;

@Service
public class CommonService {

    @Autowired
    private RestTemplate restTemplate;
    
    
    public JSONObject postForm(String url, MultiValueMap<String, String> data) {
        return restTemplate.postForObject(url, data, JSONObject.class);
    }
    
    public JSONObject postJson(String url, JSONObject json) {
        return restTemplate.postForObject(url, json, JSONObject.class);
    }
    
    
    public JSONObject getJson(String url, Object... objects) {
        return restTemplate.getForObject(url, JSONObject.class, objects);
    }
    
}
